<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>华胜后台管理</title>
		<link rel="stylesheet" type="text/css" href="css/unified.css">
		<script src="plugins/layui/layui.js"></script>
	</head>

	<body>

		<div class="breadcrumbnav">
			<span class="layui-breadcrumb " lay-separator="·">
          <a ><cite>首页</cite></a>
          <a ><cite>微信用户</cite></a>
        </span>
		</div>
		<div class="kit-doc">
			<!-- 标题 -->

			<div class="kit-doc-title">

				<fieldset>
					<legend>
						<a name="blockquote">用户</a>
					</legend>
				</fieldset>
			</div>
			<!-- 标题 end-->

			<!-- 概述 -->
			<div class="boderbox">
				<div class="rowtop">
					<button class="layui-btn addbtn openwinbtn  hidediv" id="yeschoice" data-method="yeschoice">确认选择</button>
	
                </button>
				<!--<form class="layui-form searchform" action="" id="comSearchForm">
                    <select name="city" lay-verify="">
                      <option value="oderid">用户名</option>
                      <option value="name">名称</option>
                    </select> 
                    <div class="layui-input-inline">
                      <input type="text" name="text" required lay-verify="required" placeholder="输入关键字" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-btn-group">
                      <button class="layui-btn">搜索</button>
                      <button class="layui-btn layui-btn-normal">重置</button>
                    </div>
                </form> -->

				<!--</div>-->

				<!--<div class="layui-tab-content notab">-->
				<div class="layui-tab-item layui-show">
					<table class="layui-table " lay-filter="table100" id="VIPtable"></table>

				</div>
				<!--</div>-->
				
				<!--性别处理-->
				<script type="text/html" id="sextmp"> 
			
				  {{#  if(d.sex == '1' ){ }}
				    	男
				  {{#  } else { }}
				   		 女
				  {{#  } }}
				</script>
      
				<script src="js/jquery-3.2.1.min.js"></script>
				<script type="text/javascript" src="js/allajax.js"></script>

				<script>
					layui.use(['layer', 'form', 'element', 'table'], function() {
						var layer = layui.layer,
							form = layui.form,
							element = layui.element,
							table = layui.table;
							
						var tableArray = new Array();
						VListFn();

						function VListFn() {
							//获取会员名单	
							AjaxPostFn("system/customer/user/select?page=1&pagesize=100", "{}", function(data) {
								if(data.pageInfo.size != 0) {
									$.each(data.pageInfo.list, function(idx, obj) {
										
										if(obj.customerWechat && obj.customerUserustomerUser){
											
											wechat = obj.customerWechat; //微信信息
											user = obj.customerUserustomerUser; //用户信息
											console.log(wechat.sex)
											tableArray.push({
												"wechatid": wechat.id,
												"operation": " ",
												"appId": wechat.appId,
												"openId": wechat.openId,
												"nickName": wechat.nickName,
												"headimgurl": wechat.headimgurl,
												"wechatheadimgurl": "<img src='" + wechat.headimgurl + "' alt='分类主图' class='classifyimg'>",
												"province": wechat.province,
												"sex": wechat.sex, //1 / 0
												"sex1": wechat.sex, //1 / 0
												"account": wechat.account,
												"wechatphone": wechat.phone,
												"wechatpassword": wechat.password,
												"email": wechat.email,
												"point": wechat.point,
												"type": wechat.type,
												"fromOpenId": wechat.fromOpenId,
												"status": wechat.status,
												"createDate": getMyDate(wechat.createDate),
												"updateDate": getMyDate(wechat.updateDate),
												"country": wechat.country,
												"city": wechat.city,
												"userToken": wechat.userToken,
	
												"userid": user.id,
												"username": user.username,
												"userpassword": user.password,
												"name": user.name,
												"membership": user.membership,
												"state": user.state,
												"wechatOpenid": user.wechatOpenid,
												"alipayOpenid": user.alipayOpenid,
												"mailbox": user.mailbox,
												"peopleName": user.peopleName,
												"peopleId": user.peopleId,
												"nicoName": user.nicoName,
												"gender": user.gender,
												"birthday": user.birthday,
												"joinTime": getNowFormatDate(user.joinTime),
												"lastLoginTime": getNowFormatDate(user.lastLoginTime),
												"lastLoginIp": user.lastLoginIp,
												"lastLoginRoute": user.lastLoginRoute,
												"accumulatedPoints": user.accumulatedPoints,
												"userphone": user.phone
											});
											
										}
									});

								}

								//展示已知数据
								var tableIns = table.render({
									elem: '#VIPtable',
									cols: [
										[ //标题栏
										{type:'numbers',fixed: 'left',title: '行号'},
											{
												type: 'checkbox',
												fixed: 'left'
											},{
												field: 'wechatid',
												minWidth: '0%',
												width: '0%',
												type: 'space',
												style: 'display:none'
											},{
												field: 'userid',
												minWidth: '0%',
												width: '0%',
												type: 'space',
												style: 'display:none'
											}, {
												field: 'operation',
												width: 120,
												title: '操作',
												fixed: 'left'
											}, {
												field: 'appId',
												width: 100,
												title: '公众号ID'
											}, {
												field: 'openId',
												width: 100,
												title: 'openID'
											}, {
												field: 'nickName',
												width: 100,
												title: '名称'
											}, {
												field: 'wechatheadimgurl',
												width: 100,
												title: '微信头像'
											}, {
												field: 'province',
												width: 100,
												title: '省份'
											}, {
												field: 'sex1',
												width: 100,
												title: '性别',
												templet: '#sextmp'
											}, {
												field: 'account',
												width: 100,
												title: '账号'
											}, {
												field: 'phone',
												width: 100,
												title: '电话'
											}, {
												field: 'password',
												width: 100,
												title: '密码'
											}, {
												field: 'email',
												width: 100,
												title: '邮箱'
											}, {
												field: 'point',
												width: 100,
												title: '积分'
											}, {
												field: 'type',
												width: 100,
												title: '主被动关注'
											}, {
												field: 'fromOpenId',
												width: 100,
												title: '推荐人'
											}, {
												field: 'status',
												width: 100,
												title: '状态'
											}, {
												field: 'city',
												width: 100,
												title: '地区'
											}, {
												field: 'country',
												width: 100,
												title: '国家'
											}

											//										
											//										{field: '',width: 100,title: '加入系统时间'},
											//										{field: '',width: 100,title: '加入系统时间'},

										]
									],
									data: tableArray,
									id: 'VIPtable',
									size: 'lg',
									height: 'full-250',
									even: true,

									page: true, //是否显示分页
									done: function() {
										//图片点击放大
										TopimgFn();
									}
								});
							});

						}
						
						//处理弹框的事件
						$('.openwinbtn').on('click', function() {
							var othis = $(this),
								method = othis.data('method');
							active[method] ? active[method].call(this, othis) : '';
						});
						
						
						var active = {
						//         弹出框事件
							yeschoice: function() {
								//选择当前的所选行.
								var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
								var checkStatus = table.checkStatus('VIPtable'),
									data = checkStatus.data;
								if(data.length < 1) {
									layer.msg("请至少选择一个用户")
								} else {
									var stockInstr;
									$.each(data, function(idx, obj) {
										var tf = true;
										$.each(parent.$("#VipinTable tbody tr"), function(tridx, trobj) {
											var thisopenId = parent.$("#VipinTable tbody tr:eq(" + idx + ") .wechatId").html()
											if(thisopenId === obj.wechatid) {
												tf = false;
											}
										})
										if(tf) {
											if(GetQueryString("type") == "new") {
												
											} else {
												
												stockInstr += '<tr><td onclick="deltr(' + idx + ')"><i class="layui-icon delicon">&#xe640;</i>   </td><td data-stats="0" >等待添加</td>'+
//												'<td>'+obj.openId+'</td>'+
//												'<td>'+obj.wechatid+'</td>'+
//												'<td>'+obj.userid+'</td>'+
												'<td class="userId">'+obj.userid+'</td>'+
												'<td class="wechatId">'+obj.wechatid+'</td>'+
												'<td class="openId">'+obj.openId+'</td>'+
												'<td><input type="text" class="longeditTinput nickName" value="'+obj.nickName+'" /> </td>'+
												'<td><input type="text" class="longeditTinput introduce" value="" placeholder="请输入客服介绍" /></td>'+
												'<td><input type="text" class="longeditTinput adcode" value="" /> </td>'+
												'<td><input type="text" class="longeditTinput province" value=" '+obj.province+'" /></td>'+
												
												'<td class="wechatheadimgurl">'+obj.wechatheadimgurl+'</td>'+
												'</tr>';
											}
										}
					
									});
									parent.$("#VipinTable tbody").append(stockInstr); //给父级窗口增加指定字符串
									parent.TopimgFn();//图片点击放大
									parent.layer.close(index);//关闭父级窗口的弹框
								}
							}
							
							
						}
						
					});
				</script>
			</div>
			<!-- 概述 end-->
		</div>
	</body>

</html>